package light3d;

import java.util.*;
import java.awt.*;

public class TriangleList implements Comparable<TriangleList>
{
  final int Z_PRECISION = 10000;
  int tColor;
  public double x[], y[];
  int z[];
  TriangleList next;
  public TriangleList(double x1, double y1, 
                      double x2, double y2, 
                      double x3, double y3, double pZ1, double pZ2, double pZ3, int c)
  {
    x = new double[3];
    y = new double[3];
    z = new int[3];
    x[0] = x1;
    x[1] = x2;
    x[2] = x3;

    y[0] = y1;
    y[1] = y2;
    y[2] = y3;

    z[0] = (int)(pZ1 * Z_PRECISION);
    z[1] = (int)(pZ2 * Z_PRECISION);
    z[2] = (int)(pZ3 * Z_PRECISION);

    next = null;
    tColor = c;
  }
  public TriangleList()
  {
    next = null;
  }
  public void giveNext(TriangleList t)
  {
    next = t;
  }
  public TriangleList getNext()
  {
    return next;
  }
  public double getX(int p)
  {
    return x[p];
  }
  public double getY(int p)
  {
    return y[p];
  }
  public int getZ(int p)
  {
    return z[p];
  }
  public int compareTo(TriangleList t)
  {
    for (int p = 0; p < 3; p++)
    {
      if (t.getZ(p) < z[p])
        return 1;
      else if (t.getZ(p) > z[p])
        return -1;
    }
    return 0;
  }
  public int getColor()
  {
    return tColor;
  }
}
